# 设置最低版本号
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
# 设置项目名称
project(yunyan VERSION 0.0.1 LANGUAGES CXX)

# 输出系统信息
message(STATUS "System: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")

# 设置编译器
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置库架构
set(LIB_ARCH "aarch64")
set(DEVICE_NAME "RK3588")

#  rknn_api 文件夹路径
set(RKNN_API_PATH ${CMAKE_CURRENT_SOURCE_DIR}/librknn_api)
#  rknn_api include 路径
set(RKNN_API_INCLUDE_PATH ${RKNN_API_PATH}/include)
#  rknn_api lib 路径
set(RKNN_API_LIB_PATH ${RKNN_API_PATH}/${LIB_ARCH}/librknnrt.so)



# rga
set(3RDPARTY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
set(RGA_DIR ${3RDPARTY_PATH}/rga/${DEVICE_NAME})
set(RGA_LIB ${RGA_DIR}/lib/Linux/${LIB_ARCH}/librga.so)
# jpeg turbo
set(JPEG_DIR ${3RDPARTY_PATH}/jpeg_turbo)
set(JPEG_LIB ${JPEG_DIR}/Linux/${LIB_ARCH}/libturbojpeg.a)

set(STD_DIR ${3RDPARTY_PATH}/stb_image)

# 寻找OpenCV库，使用自定义的OpenCV_DIR
find_package(OpenCV REQUIRED)
# 输出OpenCV信息
message(STATUS "include path: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "${OpenCV_VERSION}")

# 用来搜索头文件的目录
include_directories(
    ${OpenCV_INCLUDE_DIRS}
    ${RKNN_API_INCLUDE_PATH}
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${RGA_DIR}/include
    ${JPEG_DIR}/include
    ${STD_DIR}
)


add_library(imageutils SHARED
    src/utils/image_utils.cpp
)

target_link_libraries(imageutils
    ${JPEG_LIB}
    ${RGA_LIB}
)

add_library(fileutils SHARED
    src/utils/file_utils.cpp
)

add_executable(lprnet
    src/main.cpp
    src/lprnet/lprnet.cpp
)

target_link_libraries(lprnet
    fileutils
    imageutils
    ${OpenCV_LIBS}
    ${RKNN_API_LIB_PATH}
)